//
//  TopicActivityCell.m
//  u76ho
//
//  Created by m-air-01 on 15/12/29.
//  Copyright © 2015年 LV. All rights reserved.
//

#import "TopicActivityCell.h"
#import "TopicActivityCollectionViewCell.h"
#import "HomePageModel.h"
@interface TopicActivityCell ()
{
    CGSize size;
}
@end
@implementation TopicActivityCell

- (void)awakeFromNib {
    // Initialization code
    
    CGFloat width = (SCREEN_WIDTH - 40)/3;
    size = CGSizeMake(width, 50);
    self._collectionView.dataSource = self;
    self._collectionView.delegate =self;
    
    
    self._collectionView.scrollEnabled = NO;
    
//     self._collectionView.alwaysBounceVertical = YES;
//    
//    self._collectionView.alwaysBounceHorizontal= NO;
//    
    self._collectionView.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1.00];
    
    [self._collectionView registerNib:[UINib nibWithNibName:@"TopicActivityCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"TopicActivityCollectionViewCell"];
}
-(void)setPicArr:(NSArray *)picArr
{
    _picArr = picArr;
    
    [self._collectionView reloadData];
}
#pragma mark - _collectionDelegate
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _picArr.count;
}

// 设置最小行间距，也就是前一行与后一行的中间最小间隔
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    return 5;
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(10, 10, 10, 10);
}

// 设置最小列间距，也就是左行与右一行的中间最小间隔
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    return 5;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    TopicActivityCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TopicActivityCollectionViewCell" forIndexPath:indexPath];
    if ([_picArr.firstObject isKindOfClass:[commendActivityModel class]]) {
        commendActivityModel * model = _picArr[indexPath.item];
        
        cell.RightLabel.text =model.title;
        
       // NSRange range = [model.pic rangeOfString:@"|"];
        
            //NSArray * arr = [model.pic componentsSeparatedByString:@"|"];
        
        
            [cell.LeftImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",U76HOURL,model.pic]] placeholderImage:[UIImage imageNamed:@"在职公司－默认动态图.png"]];
        
            }
    
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (_collectionCellSelectedBlock) {
        _collectionCellSelectedBlock((int)indexPath.item);
    }
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return size;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
